<?php
namespace app\admin\controller;

use app\BaseController;
use think\exception\HttpException;
use think\exception\HttpResponseException;

class AdminBase extends BaseController{
    protected $adminUser = null;
    public function initialize()
    {
        parent::initialize();
        // 判断是否登录
        if($this->isLogin()){
            //跳转
            return $this->redirect(url('login/index'), 302);
        }
    }

    public function isLogin(){
        $this->adminUser = session(config("admin.session_admin"));
        if(empty($this->adminUser)){
            return false;
        }
        return true;
    }

    // 解决redirect 不能跳转
    public function redirect(...$args){
        throw new HttpResponseException(redicrect(...$args));
    }
}